from django.db import models

class Event(models.Model):
    name = models.CharField(maxlength=255)
    date = models.DateTimeField('date published', auto_now_add=True)
    capacity = models.IntegerField('Capacity', default=0)

    def __unicode__(self):
        return u'%s, %s, %d' % (self.name, self.date, self.capacity)

    def get_absolute_url(self):
        return u'/events/%d/' % (self.id,)

class Participant(models.Model):
    name = models.CharField(maxlength=255)
    event = models.ForeignKey(Event)

    def __unicode__(self):
        return u'%s' % (self.name,)

    def get_absolute_url(self):
        return u'/events/%d/' % (self.event.id,)
